
import 'package:flutter/cupertino.dart';
import 'package:hc_ui/config/hc_customer_config.dart';
import 'package:hc_ui/config/hc_default_theme_config.dart';

import 'hc_base_theme.dart';
import 'hc_common_theme.dart';

class HcAvatarGridTheme extends HcBaseTheme<HcAvatarGridTheme> {
  double? _radius;
  Color? _backgroundColor;
  Color? _borderColor;
  double? _borderWidth;
  double? _size;
  double? _vSpacing;
  double? _hSpacing;
  EdgeInsets? _padding;
  EdgeInsets? _margin;

  HcAvatarGridTheme({
    double? radius,
    Color? backgroundColor,
    Color? borderColor,
    double? borderWidth,
    double? size,
    double? hSpacing,
    double? vSpacing,
    EdgeInsets? padding,
    EdgeInsets? margin,
  })  : _radius = radius,
        _backgroundColor = backgroundColor,
        _borderColor = borderColor,
        _borderWidth = borderWidth,
        _size = size,
        _hSpacing = hSpacing,
        _vSpacing = vSpacing,
        _padding = padding,
        _margin = margin;

  @override
  void initTheme({HcCommonTheme? tempTheme}) {
    super.initTheme(tempTheme: tempTheme);
    HcAvatarGridTheme theme = HcCustomerConfig().allTheme.avatarGridTheme;
    _radius = commonTheme.radiusBase;
    _backgroundColor = commonTheme.fillMaskColor;
    _borderColor = commonTheme.borderColor;
    _borderWidth = theme.borderWidth;
    _size = commonTheme.iconSizeXxl;
    _hSpacing = commonTheme.vSpacingXxs;
    _vSpacing = commonTheme.vSpacingXxs;
    _padding = EdgeInsets.symmetric(
        vertical: commonTheme.vSpacingXxs, horizontal: commonTheme.vSpacingXxs);
    _margin = theme.margin;
  }

  @override
  HcAvatarGridTheme merge(HcAvatarGridTheme? value) {
    if (value == null) return this;
    return copyWith(
      padding: value._padding,
      margin: value._margin,
      radius: value._radius,
      backgroundColor: value._backgroundColor,
      borderWidth: value._borderWidth,
      borderColor: value.borderColor,
      size: value._size,
      vSpacing: value._vSpacing,
      hSpacing: value._hSpacing,
    );
  }

  HcAvatarGridTheme copyWith({
    double? radius,
    Color? backgroundColor,
    Color? borderColor,
    double? borderWidth,
    double? size,
    double? hSpacing,
    double? vSpacing,
    EdgeInsets? padding,
    EdgeInsets? margin,
  }) {
    return HcAvatarGridTheme(
      radius: radius ?? _radius,
      backgroundColor: backgroundColor ?? _backgroundColor,
      padding: padding ?? _padding,
      margin: margin ?? _margin,
      borderWidth: borderWidth ?? _borderWidth,
      borderColor: borderColor ?? _borderColor,
      size: size ?? _size,
      hSpacing: hSpacing ?? _hSpacing,
      vSpacing: vSpacing ?? _vSpacing,
    );
  }

  EdgeInsets get margin =>
      _margin ?? HcDefaultThemeConfig.defaultAvatarGridTheme.margin;

  EdgeInsets get padding =>
      _padding ?? HcDefaultThemeConfig.defaultAvatarGridTheme.padding;

  double get hSpacing =>
      _hSpacing ?? HcDefaultThemeConfig.defaultAvatarGridTheme.hSpacing;

  double get vSpacing =>
      _vSpacing ?? HcDefaultThemeConfig.defaultAvatarGridTheme.vSpacing;

  double get size => _size ?? HcDefaultThemeConfig.defaultAvatarGridTheme.size;

  double get borderWidth =>
      _borderWidth ?? HcDefaultThemeConfig.defaultAvatarGridTheme.borderWidth;

  Color get borderColor =>
      _borderColor ?? HcDefaultThemeConfig.defaultAvatarGridTheme.borderColor;

  Color get backgroundColor =>
      _backgroundColor ??
      HcDefaultThemeConfig.defaultAvatarGridTheme.backgroundColor;

  double get radius =>
      _radius ?? HcDefaultThemeConfig.defaultAvatarGridTheme.radius;
}
